package com.example.adapter;

import java.util.List;
import java.util.Map;

import com.example.juyixia.R;
import com.exanple.data.Activeinfo;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ActiveAdapter extends BaseAdapter {
	private List<Activeinfo> data;
    private LayoutInflater layoutInflater;
    private Context context;
	public ActiveAdapter(Context context, List<Activeinfo> data) {
	    //传入的data，就是我们要在listview中显示的信息
	        this.context = context;
	        this.data = data;
	        this.layoutInflater = LayoutInflater.from(context); 
	    }
	    //这里定义了一个类，用来表示一个item里面包含的东西，像我的就是一个imageView和三个TextView，按自己需要来
	    public class Info {
	        public TextView activename;
	        public TextView parter;
	        public TextView activetime;
	    }
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return data.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		 Info info = new Info();
	        convertView = layoutInflater.inflate(R.layout.item_myactive, null);
	        info.activename = (TextView) convertView
	                .findViewById(R.id.active_name);
	        info.parter = (TextView) convertView
	                .findViewById(R.id.active_parter);
          info.activetime= (TextView) convertView
	                .findViewById(R.id.active_time);
	        //设置数据
	    
	        info.activename.setText((String) data.get(position).getActivename());
	        info.parter.setText((String) data.get(position).getParter());
	        info.activetime.setText((String) data.get(position).getActivetime());
	       
	        return convertView;
	}

}
